import { initEdge } from '../shape/edge'
import { EdgeKeyType } from '../types'
import { setCssVariable } from '../utils'

/**
 * 边沿配置
 */

export const edgeConfig = {
    size: {
        height: 50,
        low: 0,
        high: 0,
        rise: 0,
        neg: 0,
    },
    speed: 0.5,
    time: {
        low: 0,
        high: 0,
        rise: 0,
        neg: 0,
    },
    defaultTime: {
        low: 2500,
        high: 2500,
        rise: 500,
        neg: 500,
    },
    setSpeed(v: number = 1) {
        this.speed = v
        const keys = Object.keys(this.time) as EdgeKeyType[]
        for (const key of keys) {
            this.time[key] = this.defaultTime[key] * v
            this.size[key] = (this.defaultTime[key] * v) / 10 / 4
        }
        initEdge()
    },
}

export function initEdgeConfig() {
    edgeConfig.setSpeed()
    setCssVariable('--edge-height', `${edgeConfig.size.height}px`)
}
